package com.example.tkserver.controller;

import com.example.tkserver.entity.Article;
import com.example.tkserver.service.interfaces.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    ArticleService articleService;

    @RequestMapping("/publishArticle")
    public String publishArticle(@RequestBody Article article){
        articleService.publishArticle(article);
        return "success";
    }

    @RequestMapping("/getRecommendArticleNum")
    public int getRecommendArticleNum(){
        return articleService.getRecommendArticleNum();
    }

    @RequestMapping("/getRecommendArticle")
    public List<Article> getRecommendArticle(int start,int end){
        return articleService.getRecommendArticle(start,end);
    }
}
